package com.systop.dxjj.modules.teacher.mapper;

import com.systop.dxjj.common.pojo.Student;
import com.systop.dxjj.common.pojo.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {
    /**
     * 查询所有教员信息
     */
    @Select("select * from teacher")
    List<Teacher> selectAllTeachs();

    /**
     * 教员登录
     */
    @Select("select teachphone,teachpassword from teacher where teachphone=#{teachphone} and teachpassword=#{teachpassword}")
    Teacher loginTeach(Teacher teacher);

    /**
     *根据teachname查询教员信息
     */
    @Select("select * from teacher where teachname=#{teachname}")
    Teacher selectTeachByTeachname(String teachname);

    /**
     *根据teachphone查询教员信息
     */
    @Select("select * from teacher where teachphone=#{teachphone}")
    Teacher selectTeachByTeachphone(String teachphone);
    /**
     *根据id查询教员信息
     */
    @Select("select * from teacher where teachid=#{teachid}")
    Teacher selectTeachById(Integer id);

    /**
     * 根据姓名查询教员姓名
     */
    @Select("select * from teacher where teachname=#{teachname}")
    List<Teacher> selectStudentByName(String name);

    /**
     * 模糊查询
     */
    @Select("select * from teacher where teachname like CONCAT('%', #{teachname}, '%')")
    List<Teacher> selectStudentByVagueName(String name);

    /**
     *插入教员信息
     */

    @Insert("insert into teacher(teachname,teachsex,teachphone,teachpassword,teachschool,teachgrade) values (#{teachname},#{teachsex},#{teachphone},#{teachpassword},#{teachschool},#{teachgrade})")
    int insertTeach(Teacher teacher);

    /**
     *删除教员信息
     */
    @Delete("delete from teacher where teachid=#{teachid}")
    int deleteTeach(Integer id);

    /**
     *更新教员信息
     */
    @Update("update teacher set teachname=#{teachname},teachsex=#{teachsex},teachphone=#{teachphone},teachpassword=#{teachpassword},teachschool=#{teachschool},teachgrade=#{teachgrade} where teachid=#{teachid}")
    int updateTeach(Teacher teacher);

    @Options(useGeneratedKeys=true,keyProperty="teachid",keyColumn="teachid")
    @Insert("insert into teacher(teachname,teachsex,teachphone,teachschool,teachgrade) values (#{teachname},#{teachsex},#{teachphone},#{teachschool},#{teachgrade})")
    int insertTeach2(Teacher teacher);

    @Select("select teacher.teachid from teacher where teachname=#{teachname}")
    Integer selectIdByName(String teachname);

}
